import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import qiankun from "vite-plugin-qiankun";

export default defineConfig({
  plugins: [
    vue(),
    qiankun("vue3-app", {
      useDevMode: true, // 在开发模式下启用，便于调试
    }),
  ],
  base:
    process.env.NODE_ENV === "development" ? "//localhost:8091" : "/vue-app",
  server: {
    port: 8091,
    host: "0.0.0.0",
    cors: true,
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
    },
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  build: {
    lib: {
      entry: "src/main.ts",
      name: "vue3-app",
      formats: ["umd"],
      fileName: "vue3-app",
    },
  },
});
